import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '../views/LoginView.vue'
import RegView from '../views/RegView.vue'
import IndexView from '../views/IndexView.vue'

const includPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return includPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    redirect:'/index/barConfig'
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/index',
    name: 'index',
    component: IndexView,
	children:[
		{
			path: 'barConfig',
			name: 'BarConfigView',
			component: () => import('../views/BarConfigView.vue')
		},
		{
			path: 'lineConfig',
			name: 'LineConfigView',
			component: () => import('../views/LineConfigView.vue')
		},
		{
			path: 'pieConfig',
			name: 'PieConfigView',
			component: () => import('../views/PieConfigView.vue')
		},
		{
			path: 'radarConfig',
			name: 'RadarConfigView',
			component: () => import('../views/RadarConfigView.vue')
		},
		{
			path: 'gaugeConfig',
			name: 'GaugeConfigView',
			component: () => import('../views/GaugeConfigView.vue')
		},
	]
  },
  {
    path: '/reg',
    name: 'reg',
    component: RegView
  }
]

const router = new VueRouter({
  mode: 'hash', // 使用 hash 模式
  base: process.env.BASE_URL,
  routes
})

export default router
